package com.leeon.generics;

import java.util.Arrays;
import java.util.List;

public class GenericReading {

	static <T> T readExact(List<T> list) {
		return list.get(0);
	}

	static List<Apple> apples = Arrays.asList(new Apple());
	static List<Friut> friuts = Arrays.asList(new Friut());

	static void f() {
		Apple a = readExact(apples);
		Friut f = readExact(friuts);
		f = readExact(apples);
	}

	static class Reader<T> {
		T readExact(List<T> list) {
			return list.get(0);
		};
	}
	static void f2(){
		Reader<Friut> fReader = new Reader<Friut>();
		Friut f = fReader.readExact(friuts);
		//Friut a = fReader.readExact(apples);
	}
	static class CovariantReader<T> {
		T readConvariant(List<? extends T> list){
			return list.get(0);
		}
	}
	static void f3(){
		CovariantReader<Friut> fReader = new CovariantReader<Friut>();
		Friut f = fReader.readConvariant(friuts);
		Friut d = fReader.readConvariant(apples);
	}

	public static void main(String[] args){
		f();f2();f3();
	}
	
}
